export function identityNoChange() {
    const self = this;
    let identityNo = self.$$("text_input_bwe56z").cValue;
    if (!/^\d{17}[\dXx]$/.test(identityNo)) {
        document.getElementById('result').innerText = '身份证格式不正确';
        return;
    }

    const birth = identityNo.slice(6, 8);
    const year = parseInt(birth.slice(0, 4));
    const month = parseInt(birth.slice(4, 2));
    const day = parseInt(birth.slice(6, 2));

    // 计算年龄
    const today = new Date();
    let age = today.getFullYear() - year;
    if (today.getMonth() + 1 < month || (today.getMonth() + 1 === month && today.getDate() < day)) {
        age--;
    }

    // 判断性别
    const gender = parseInt(id.charAt(16)) % 2 === 0 ? '2' : '1';

    self.$$("radio_cqh6ou").cValue = gender;
    self.$$("number_input_28g9zq").cValue = age;
}
